﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

using Xc.HyperTerminal.ViewModels;

namespace Xc.Demos.HyperTerminal.Models
{
    public class ChatTemplateSelecter: DataTemplateSelector
    {
        /// <summary>
        /// 左侧显示时的模板
        /// </summary>
        public DataTemplate LeftTemplate { get; set; }
        /// <summary>
        /// 中间显示时的模板
        /// </summary>
        public DataTemplate CenterTemplate { get; set; }
        /// <summary>
        /// 右侧显示时的模板
        /// </summary>
        public DataTemplate RightTemplate { get; set; }
        /// <summary>
        /// 平铺显示时的模板
        /// </summary>
        public DataTemplate StretchTemplate { get; set; }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is ChatInfo info)
            {
                switch (info.Alignment)
                {
                    case HorizontalAlignment.Left:
                        return LeftTemplate;
                    case HorizontalAlignment.Center:
                        return CenterTemplate;
                    case HorizontalAlignment.Right:
                        return RightTemplate;
                    case HorizontalAlignment.Stretch:
                       return StretchTemplate;
                    default:
                        break;
                }
            }
            return base.SelectTemplate(item, container);
        }
    }
}
